package com.zyhl.gmall.product.mytest.demo07;

import java.util.*;
import java.util.stream.Stream;

/**
 * 生成Stream流的方式
 *    Collection体系集合
 *      使用默认方法stream()生成流， default Stream stream()
 *    Map体系集合
 *      把Map转成Set集合，间接的生成流
 *    数组
 *      通过Stream接口的静态方法of(T... values)生成流
 */
public class StreamDemo2 {

    public static void main(String[] args) {
        //Collection体系的集合可以使用默认方法stream()生成流
        List<String> list = new ArrayList<String>();
        Stream<String> listStream = list.stream();

        Set<String> set = new HashSet<String>();
        Stream<String> SetStream = set.stream();

        //Map体系的集合间接的生成流
        HashMap<String, Integer> map = new HashMap<>();
        Stream<String> ktyStream = map.keySet().stream();
        Stream<Integer> valuesStream = map.values().stream();
        Stream<Map.Entry<String, Integer>> entryStream = map.entrySet().stream();

        //数组可以通过Stream接口的静态方法of(T... values)生成流
        String[] strArray = {"hello","翠花","发发发"};
        Stream<String> strArray1 = Stream.of(strArray);
        Stream<String> strArray2 = Stream.of("hello", "world", "java");
        Stream<Integer> strArray3 = Stream.of(10, 20, 30);


    }
}
